package com.yizn.learn.annotation;

import java.lang.reflect.Field;

/**
 * 注释器解释器
 *
 * @author yisl
 * @create 2019-06-07 11:40
 */
public class FruitUtil {

    public static String getFruitProvide(Class<?> tClass){
        String provide = "供应商信息";

        Field[] fields = tClass.getDeclaredFields();
        for (Field field : fields){
            if (field.isAnnotationPresent(FruitProvide.class)){
                FruitProvide fruitProvide = field.getAnnotation(FruitProvide.class);
                provide =  " 供应商编号:" + fruitProvide.id() + " 供应商名称:"
                        + fruitProvide.name() + " 供应商地址:"+ fruitProvide.address();
            }
        }

        return provide;
    }
}
